/**
 * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.cms.template.service;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.cms.template.entity.CmsTemplate;
import com.jeeplus.modules.cms.template.mapper.CmsTemplateMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 模板Service
 *
 * @author Sawyer
 * @version 2020-12-21
 */
@Service
@Transactional(readOnly = true)
public class CmsTemplateService extends CrudService<CmsTemplateMapper, CmsTemplate> {

    @Override
    public CmsTemplate get(String id) {
        return super.get(id);
    }

    @Override
    public List<CmsTemplate> findList(CmsTemplate cmsTemplate) {
        return super.findList(cmsTemplate);
    }

    @Override
    public List<CmsTemplate> findAllList(CmsTemplate entity) {
        return findList(entity);
    }

    @Override
    public Page<CmsTemplate> findPage(Page<CmsTemplate> page, CmsTemplate cmsTemplate) {
        return super.findPage(page, cmsTemplate);
    }

    @Transactional(readOnly = false)
    @Override
    public void save(CmsTemplate cmsTemplate) {
        super.save(cmsTemplate);
    }

    @Transactional(readOnly = false)
    @Override
    public void delete(CmsTemplate cmsTemplate) {
        super.delete(cmsTemplate);
    }

    /**
     * 根据英文名称查找模板
     *
     * @param enName 英文名称
     * @return CmsTemplate or null
     */
    public CmsTemplate findTemplateByEnName(String enName) {
        CmsTemplate condition = new CmsTemplate();
        condition.setEnname(enName);
        List<CmsTemplate> resultList = findList(condition);
        return null != resultList && resultList.size() > 0 ? resultList.get(0) : null;
    }
}
